import top.malaoshi.data.DataColumn;
import top.malaoshi.data.DataQuery;
import top.malaoshi.data.DataRow;
import top.malaoshi.data.DataTable;
import top.malaoshi.util.Out;

import java.util.ArrayList;
import java.util.List;

public class S8测试索引清空数据_删除数据 {
    static DataTable ready(){
        DataTable dt = new DataTable("t_user");
        Out.println("表名：",dt.getName());

//        dt.columns().add("id");
        dt.columns().add("id", DataColumn.Type.INT);
        dt.columns().add("username", DataColumn.Type.TEXT);
        dt.columns().add("password", DataColumn.Type.TEXT);
        dt.columns().add("age", DataColumn.Type.INT);
        dt.columns().add("height", DataColumn.Type.DOUBLE);
        dt.columns().add("birthday", DataColumn.Type.TEXT);

        dt.indexManager.addIndex("id");
        dt.indexManager.addIndex("age");
        dt.indexManager.addIndex("height");
        dt.indexManager.addIndex("password");

        dt.rows().add(new Object[]{1,"lilei","123456",20,1.83,"2000-06-01"});
        DataRow drHmm = dt.rows().add(new Object[]{2, "韩梅梅", "666", 22,1.65,"2000-07-01"});

        // 创建 DataRnow
        DataRow dataRow = dt.newRow();
//        通过索引设置数据
        dataRow.setValue( 0,3 );
        dataRow.setValue( 1,"lucy" );
        dataRow.setValue( 2,"333" );
        dataRow.setValue( 3,22);
        dataRow.setValue( 4,1.73 );
        dataRow.setValue( 5,"2000-08-01" );
        dt.rows().add(dataRow);

        // 创建 DataRnow
        DataRow dataRow2 = dt.newRow();

        dataRow2.setValue("id",4);
        dataRow2.setValue("username","lili");
        dataRow2.setValue("password","555");
        dataRow2.setValue("age",28);
        dataRow2.setValue("height",1.65);
        dataRow2.setValue("birthday","2000-09-01");
        dt.rows().add(dataRow2);

        dt.rows().add(new Object[]{5,"张三","123",20,1.83,"2000-10-01"});
        dt.rows().add(new Object[]{6,"李四","124",30,1.73,"2000-11-01"});
        dt.rows().add(new Object[]{7,"杜子腾","125",35,1.82,"2000-12-01"});
        dt.rows().add(new Object[]{8,"史珍香","126",19,1.68,"2000-03-01"});
        dt.rows().add(new Object[]{9,"小明","127",10,0.9,"2015-03-01"});
        dt.rows().add(new Object[]{10,"张大","123456",20,1.83,"2000-10-01"});

        return dt;
    }
    public static void main(String[] args) {
        DataTable table = ready();

        Out.println("索引",table.indexManager.getIndexes());
//        table.rows().clear();
        DataRow dataRow = table.select("id", DataQuery.Option.eq, 8)[0];
        table.rows().remove(dataRow);


    }
}
